package com.hoyue.service;

import com.hoyue.bean.Info;
import com.hoyue.dao.InfoDao;
import com.hoyue.dao.impl.InfoDaoImpl;
import com.hoyue.utils.Page;

import java.sql.SQLException;
import java.util.List;

/**
 * @author Hoyue_network1
 * @version 1.0
 * Creat by 2018/8/24 16:49
 */
public class InfoService {
	InfoDao infoDao = new InfoDaoImpl();

	public List<Info> getAllInfo() {
		try {
			return infoDao.getAllInfo();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void addInfo(Info info) {
		try {
			infoDao.addInfo(info);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void delete(int id) {
		try {
			infoDao.deleteInfo(id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void updateInfo(Info info) {
		try {
			infoDao.updateInfo(info);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public String getAddressById(int id) {
		try {
			return infoDao.getAddressById(id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public List<Info> searchInfo(String search) {
		try {
			return infoDao.searchInfo(search);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public Page<Info> getPicPage(int page) {
		try {
			return infoDao.getPage(page,"information where picture=1");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public Page<Info> getNoPicPage(int page) {
		try {

			return infoDao.getPage(page,"information where picture=0");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
